package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.dto.PageDto;
import com.qf.mapper.DtsCouponMapper;
import com.qf.pojo.DtsAd;
import com.qf.pojo.DtsCoupon;
import com.qf.service.DtsCouponService;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project E-commercebackGroundManagementSystem
 * @date 2022/9/25 11:15
 */
@Service
public class DtsCouponServiceImpl  implements DtsCouponService {
    @Autowired
    private DtsCouponMapper dtsCouponMapper;
    @Override
    public Page<DtsCoupon> selectPage(PageDto pageDto) {
        return dtsCouponMapper.selectPage(new Page<DtsCoupon>(pageDto.getPage(), pageDto.getLimit()), new QueryWrapper<DtsCoupon>().orderBy
                (!StringUtils.isEmpty(pageDto.getSort()), "asc".equalsIgnoreCase(pageDto.getOrder()), pageDto.getSort()).
                eq(pageDto.getType()!=null,"type",pageDto.getType()).eq(pageDto.getStatus()!=null,"status",pageDto.getStatus()).eq("deleted", false) );
    }

    @Override
    public DtsCoupon selectById(Integer id) {
        return dtsCouponMapper.selectById(id);
    }

    @Override
    public void insert(DtsCoupon dtsCoupon) {
         dtsCouponMapper.insert(dtsCoupon);
    }

    @Override
    public void update(DtsCoupon dtsCoupon) {
 dtsCouponMapper.updateById(dtsCoupon);
    }

    @Override
    public void delete(DtsCoupon dtsCoupon) {
    dtsCouponMapper.updateById(dtsCoupon);
    }
}
